package com.example.mobile2032021606130zlw0420;

import android.content.Context;
import android.graphics.drawable.Drawable;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import java.util.List;

public class Adapter2 extends RecyclerView.Adapter<Adapter2.shipe> {
    private Context context;
    private int tupia[];
    private String wenzi[];

    public Adapter2(Context context, int[] tupia, String[] wenzi) {
        this.context = context;
        this.tupia = tupia;
        this.wenzi = wenzi;
    }

    @NonNull
    @Override
    public shipe onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        return new shipe(View.inflate(context,R.layout.adapterbuju,null));
    }

    @Override
    public void onBindViewHolder(@NonNull shipe holder, int position) {
         holder.tupian.setImageResource(tupia[position]);
         holder.textView.setText(wenzi[position]);

    }

    @Override
    public int getItemCount() {
        return tupia.length;
    }

    public class shipe extends RecyclerView.ViewHolder {
        private ImageView tupian;
        private TextView textView;
        public shipe(@NonNull View itemView) {
            super(itemView);
            textView=itemView.findViewById(R.id.textvi);
            tupian=itemView.findViewById(R.id.tupia);
        }
    }
}
